<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <button>点击发送</button>
<script>
    var btn = document.getElementsByTagName('button')[0];
    var timer = null;
    btn.onclick = function(){
        // clearInterval(timer);//如果没有disabled  需要先清楚 不然重复点击 会出现重叠 计时器 加速
        this.disabled = true;
        var _this = this;
        var n = 10;
        timer = setInterval(sendMessage,1000);//定时器起个名字
        // setInterval(sendMessage,1000);
        function sendMessage(){
            n--;
            if(n>=0){
              _this.innerHTML = "剩余"+n+"秒";  
            }else{
                _this.innerHTML = "重新发送";
                _this.disabled = false;
                clearInterval(timer);//清除定时器
                n = 10;
            }
        }
    }
</script>
</body>
</html>